const bus = {
  message:{},
  on(type, cb){
    if(this.message[type]){
      this.message[type].push(cb);
    }else{
      this.message[type] = [cb];
    }
  },
  emit(type){
    const arg = [...arguments].slice(1);
    if(!this.message[type]) return;
    this.message[type].forEach(val=>{
      val(...arg);
    })
  }
}

export default bus;